<template>
    <div class="main">
        <img :src="imglist[i].picUrl" alt="">
        <ul>
            <li v-for="(itemn, index) in imglist.length" :key="index" :class="{ li: index == i }"></li>
        </ul>

    </div>
</template>

<script>
import { reactive, toRefs } from 'vue';
export default {
    props: {
        imglist: {
            type: Array,

        },
    },
    setup(props) {
        console.log(props);
        const data = reactive({
            i: 0
        })
        setInterval(() => {
            if (data.i < props.imglist.length - 1) {
                data.i++
            } else {
                data.i = 0
            }
        }, 1000)
        return { ...toRefs(data) }
    }
}
</script>

<style lang="scss" scoped>
.main {
    width: 100%;
    height: 200px;

    >img {
        width: 100%;
        height: 100%;
    }
}

ul {
    width: 160px;
    margin: auto;
    position: relative;
    top: -40px;
    display: flex;
    justify-content: space-between;

    li {
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background-color: #ccc;
    }

    .li {
        background-color: #fff;
    }
}
</style>